<template>
  <div>
    <div v-for="(obj, index) in arr" :key="index">
      <input min="0" v-model.number="obj.count" type="number" />
      <span>{{ obj.goodsName }}</span>
      <span v-if="obj.count == 0">卖光了</span>
    </div>
    <p>总数：{{ sum }}</p>
  </div>
</template>

<script>
export default {
  props: ["arr"],
  data() {
    return {
      num: "",
    };
  },
  computed: {
    sum() {
      return this.arr.reduce((num, obj) => (num += obj.count), 0);
    },
  },
};
</script>

<style scoped>
span {
  display: inline-block;
  width: 100px;
  margin-left: 10px;
}
</style>